(function () {

    angular
        .module('contactus')
        .controller('ContactusController', [
            "NgMap",
            ContactusController
        ]);

    /**
     * Controller
     * @constructor
     */
    function ContactusController(NgMap) {
        var vm = this;
        this.googleMapsUrl="https://maps.googleapis.com/maps/api/js?key=AIzaSyBS_WC-_UN3pqmTX6Dp9KKYzCvJjnBtxXk";
        this.latitude = "11.4126367";
        this.longitude = "76.6876518";
        this.customIcon = {
            "scaledSize": [32, 32],
            "url": "http://www.cliparthut.com/clip-arts/823/arrowhead-clip-art-823528.png"
        };
        NgMap.getMap().then(function(map) {
            console.log(map.getCenter());
            console.log('markers', map.markers);
            console.log('shapes', map.shapes);
            vm.showCustomMarker= function(evt) {
                map.customMarkers.foo.setVisible(true);
                map.customMarkers.foo.setPosition(this.getPosition());
            };
            vm.closeCustomMarker= function(evt) {
                this.style.display = 'none';
            };
        });

        this.contactList = [{
            "name": "Thomas"
        }];
        this.getTitle = function (tile) {
            return tile.title;
        };
        this.tiles = buildGridModel({
            icon : "svg-",
            title: "Svg-",
            background: ""
        });

        function buildGridModel(tileTmpl){
            var it, results = [ ];

            for (var j=0; j<4; j++) {

                it = angular.extend({},tileTmpl);
                /*it.icon  = it.icon + (j+1);*/
                it.icon  = it.icon + 5;
                it.title = it.title + (j+1);
                it.span  = { row : 1, col : 1 };

                switch(j+1) {
                    case 1:
                        it.background = "red";
                        it.title = "Thomas<9446954482>";
                        /*it.span.row = it.span.col = 2;*/
                        break;

                    case 2: it.background = "green";
                        it.title = "Gijo<9947171998>";
                        break;
                    case 3: it.background = "darkBlue";
                        it.title = "Eldho<9496334088>";
                        break;
                    case 4:
                        it.background = "blue";
                        it.title = "Binoy<9447226524>";
                        /*it.span.col = 2;*/
                        break;

                    case 5:
                        it.background = "yellow";
                        /*it.span.row = it.span.col = 2;*/
                        break;

                    case 6: it.background = "pink";          break;
                    case 7: it.background = "darkBlue";      break;
                    case 8: it.background = "purple";        break;
                    case 9: it.background = "deepBlue";      break;
                    case 10: it.background = "lightPurple";  break;
                    case 11: it.background = "yellow";       break;
                }

                results.push(it);
            }
            return results;
        }

        /**
         * No functionality here
         */
    }
})();
